<!DOCTYPE html>
<html>
<head>
<base href="http://localhost">
    <meta charset="UTF-8">
</head>
<body>
<form action="" method="post">
<h2>添加图书</h2>
&nbsp;&nbsp;ISBN:<input type="text" name="ISBN">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;书名:<input type="text" name="name"><br/><br/>
&nbsp;&nbsp;定价:<input type="text" name="price">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;印刷:<input type="text" name="print"><br/><br/>
&nbsp;&nbsp;主编:<input type="text" name="editor">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;字数:<input type="text" name="wordnum"><br/><br/>
出版社:<input type="text" name="press">&nbsp;&nbsp;&nbsp;
出版日期:<input type="text" name="pressdate"><br/><br/>
内容摘要:<br/><div id="div1" rows="10" cols="140"><p>这里填写书籍的内容摘要信息</p></div><br/><br/>
<textarea id="text1"  name="contentsinfo" style="display:none"></textarea>
备注信息:<br/><div id="div2" rows="10" cols="140"><p>这里填写书籍的备注信息</p></div><br/><br/>
<textarea id="text2" name="othersinfos" style="display:none"></textarea>
<input type="reset" name="reset" value="重置">&nbsp;&nbsp;&nbsp;
<input type="submit" name="submit" value="添加">
</form>
<?php 

if(isset($_POST["submit"])&&$_POST["submit"]=="添加"){
	include_once("database.php");
	date_default_timezone_set("UTC");
	$nowdate=date("Y-m-d H:m:s");//当前时间(写入时间)
	$ISBN=$_POST['ISBN'];//书的ISBN号
	$name=$_POST['name'];//书的名字
	$price=$_POST['price'];//书的价格
	$print=$_POST['print'];//书的印刷厂家
	$editor=$_POST['editor'];//书的主编
	$wordnum=$_POST['wordnum'];//书的字数
	$press=$_POST['press'];//书的出版社
	$pressdate=$_POST['pressdate'];//书的出版日期
	$contentsinfo=$_POST['contentsinfo'];//书的内容简介
	$othersinfos=$_POST['othersinfos'];//书的备注信息
	$insertbooks="insert into books(ISBN,name,price,print,editor,press,pressdate,contentsinfo,wordnum,othersinfos,insertdate,state) values('$ISBN','$name',$price,'$print','$editor','$press','$pressdate','$contentsinfo','$wordnum','$othersinfos','$nowdate',1)";
	@mysql_query($insertbooks) or die("插入新书失败:".mysql_error()."<br/>");
	echo "<script>alert('添加图书成功!');</script>";
}
?>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/wangEditor.min.js"></script>
<script type="text/javascript">
var E = window.wangEditor
        var editor1 = new E('#div1')
        var $text1 = $('#text1')
        editor1.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $text1.val(html)
        }
        editor1.create()


        var editor2 = new E('#div2')
        var $text2 = $('#text2')
        editor2.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $text2.val(html)
        }
        editor2.create()
</script>
</body>
</html>